<template>
  <div class="aa">
    <div class="header">
      <div class="adress">
        <span @click="goPosition">郑州</span>
        <van-icon name="arrow-down" class="arr" />
      </div>
      <input class="xx" type="text" placeholder="   搜影片、影院、影人" />
      <div class="serch">
        <van-icon @click="tooo" size="13" color="#7A7A7A" name="search" />
      </div>
    </div>

    <swiper ref="mySwiper" :options="swiperOptions">
      <swiper-slide v-for="(item, index) in imgListL" :key="index" class="per">
        <img :src="item" alt />
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>

    <div class="mid" @click="goMovie">
      <div class="oronge"></div>
      <div class="title">热映影片</div>

      <swiper ref="mySwiper" :options="swiperxx">
        <swiper-slide v-for="(item, index) in list" :key="index">
          <img class="img1" :src="item.small" alt />
          <p>{{ item.title }}</p>
          <button class="btn" @click="goBuy">购票</button>
        </swiper-slide>

        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
    <div class="mid-a" @click="goNow">
      <div class="oronge"></div>
      <div class="title">即将上映</div>
      <swiper ref="mySwiper" :options="swiperaa">
        <swiper-slide v-for="(item, index) in list" :key="index">
          <img class="img1" :src="item.small" alt />
          <p>{{ item.title }}</p>
          <p class="p2">{{ item.show_date[0] }}</p>
        </swiper-slide>

        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
    <div class="mid-c">
      <div class="oronge"></div>
      <div class="title">精选预告</div>
      <swiper ref="mySwiper" :options="swiperrr">
        <swiper-slide v-for="(item, index) in list3" :key="index">
          <video
            class="video1"
            :src="item.video[0]"
            controls="controls"
            :poster="item.movie.large"
          ></video>
        </swiper-slide>

        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
import ban1 from '@/assets/images/home/banner1.png'
import ban2 from '@/assets/images/home/banner2.png'
import axios from 'axios'
import BScroll from '@better-scroll/core'
export default {
  data() {
    return {
      list: [],
      list3: [],
      imgListL: [ban1, ban2],
      swiperOptions: {
        slidesPerView: 1.2,
        // spaceBetween: 5,
        centeredSlides: true,
        loop: true,
        pagination: {
          el: '.swiper-pagination',
          clickable: true,
        },
      },
      swiperxx: {
        slidesPerView: 3.2,
        pagination: {
          el: '.swiper-pagination',
        },
        // Some Swiper option/callback...
      },
      swiperaa: {
        slidesPerView: 2.8,
        pagination: {
          el: '.swiper-pagination',
        },
        // Some Swiper option/callback...
      },
      swiperrr: {
        slidesPerView: 1.1,
        pagination: {
          el: '.swiper-pagination',
        },
        // Some Swiper option/callback...
      },
    }
  },
  created() {
    axios
      .get(`http://bufantec.com/api/douban/movie/in_theaters`)
      .then((res) => {
        //    console.log(res.data.data.list);
        this.list = res.data.data.list
        console.log(this.list)
      })
    axios
      .get(`http://bufantec.com/api/douban/movie/selectPreview`)
      .then((res) => {
        //    console.log(res.data.data.list);
        this.list3 = res.data.data
        console.log(this.list3[0])
      })
  },
  methods: {
    tooo() {
      this.$router.push({ name: 'search' })
    },
    goPosition() {
      this.$router.push({ name: 'search' })
    },
    goBuy() {
      this.$router.push({ path: 'cinema/detail' })
    },
    goMovie() {
      this.$router.push({ name: 'movie' })
    },
    goNow() {
      this.$router.push({ name: 'now' })
    },
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper
    },
  },
  mounted() {},
}
</script>

<style scoped lang="scss">
.aa {
  background: #22262d;
}
.header {
  padding: 0 40px;
  height: 88px;
  background-color: #22262d;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  color: #f5f5f5;
  .xx {
    font-size: 28px;
    color: #7a7a7a;
    background: #33363d;
    width: 518px;
    height: 40px;
    border: 0px;
    background: #33363d;
    border-radius: 26px;
  }
  .adress {
    opacity: 0.78;
    font-size: 28px;
    .arr {
      vertical-align: middle;
    }
  }
}
.wrapper {
  height: 300px;
  background: red;
  padding: 0 10px;
  .content {
    li {
      height: 50px;
      background: blue;
      margin-bottom: 20px;
    }
  }
}
.per {
  width: 670px;
  height: 290px;
  transform: scale(0.8);
  img {
    width: 100%;
  }
}
.swiper-slide-active,
.swiper-slide-duplicate-active {
  transform: scale(1);
}
.oronge {
  margin-top: 10px;
  width: 8px;
  height: 34px;
  margin-left: 40px;
  float: left;
  background-image: linear-gradient(90deg, #f26182 5%, #f1a064 100%);
}
.title {
  font-size: 36px;
  color: #dfdfdf;
  margin-left: 58px;
}
.mid {
  height: 412px;
  .swiper-slide {
    width: 180px;

    margin-top: 16px;
  }
  .img1 {
    margin-left: 48px;
    width: 180px;
    height: 244px;
    border-radius: 22px;
  }
  p {
    margin-top: 12px;
    margin-left: 48px;
    font-size: 24px;
    color: #dfdfdf;
  }

  .btn {
    margin-top: 7px;
    margin-left: 68px;
    width: 100px;
    height: 44px;
    background-image: linear-gradient(150deg, #f25b86 0%, #f1ac5e 100%);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    border-radius: 22px;
    border: 0px;
    font-size: 24px;
    color: #dfdfdf;
    text-align: center;
    line-height: 100%;
  }
}

.mid-a {
  margin-top: 60px;

  .swiper-slide {
    width: 240px;
    height: 430px;
    margin-top: 16px;
  }
  .img1 {
    margin-left: 28px;
    width: 240px;
    height: 324px;
    border-radius: 22px;
  }
  p {
    margin-top: 12px;
    margin-left: 48px;
    font-size: 24px;
    color: #dfdfdf;
  }
  .p2 {
    margin-top: 2px;
    font-size: 24px;
    color: #dfdfdf;
    opacity: 0.55;
  }
}
.mid-c {
  height: 600px;

  margin-top: 48px;
}
.on {
  background: #23262d;
}
.swiper-slide {
  width: 636px;
  height: 370px;
}

.video1 {
  margin-top: 18px;
  margin-left: 40px;
  width: 636px;
  height: 370px;
  object-fit: cover;
  margin-right: 32px;
  border-radius: 22px;
}
</style>
